package pl.edu.agh.inpema.core.environment;

import javax.jms.JMSException;

import pl.edu.agh.inpema.core.dataBase.DataBase;
import pl.edu.agh.inpema.core.dataBase.DataBaseFactory;

public class EnvironmentFactory {
	
	public EnvironmentFactory() {
		
	}
	
	public Environment createNewEnvironment(String xmlConf) {
		EnvironmentInfo info = new EnvironmentInfo();
		info.setXmlConfiguration(xmlConf);
		Environment env = new Environment(info);
		env.configure();
		return env;
	}
	
	public Environment createEnvironmentById(int envId) {
		DataBase dataBase = DataBaseFactory.getDataBase();
		EnvironmentInfo info = dataBase.getEnvironmentInfo(envId);
		dataBase.closeConnection();
		if (info == null)
			return null;
		Environment env = new Environment(info);
		env.configure();
		return env;
	}	
}
